 ! ******* Feld fuer Pfaddatenverarbeitung ***********************************
_cur_l=0
_snn=0
segmente=4
punkte=200
*set,_path
*dim,_path,table,segmente*punkte,8
!     _path(i,1) = circumferential distance
!     _path(i,2) = Az
!     _path(i,3) = Br
!     _path(i,4) = mechanical angle (D)
!     _path(i,5) = PV02 (integran)
!     _path(i,6) = torq (torque)
!  number of data points in the _path array = _i_s in this array
!  _cur_l = total length of the path
_path(0,0)=1e-7
_path(0,1)=1
_path(0,2)=2
_path(0,3)=3
_path(0,4)=4
_path(0,5)=5
_path(0,6)=6
_path(0,7)=7
_path(0,8)=8

CMSEL,S,KSTATOR 
ALLSEL,BELOW,AREA   
csys,1  
NSEL,a,LOC,X,0,rinnen+jochdicke2+delta/2
cm,_nstat,node

! loop ueber alle Segmente ******************************************************

_jj=1
 *do,_jj,1,segmente,1
   csys,1
   cmsel,s,_nstat
   nsel,r,loc,y,(_jj-1)*360/segmente,_jj*360/segmente
   local,100,1
   cscir,100,1
   *if,_wa,gt,180,then
   cscir,100,0
   *endif
    !set,last
   *get,_we,node,,mxloc,y               ! Endwinkel
   *get,_wa,node,,mnloc,y               ! Anfangswinkel
   *if,(_jj-1)*360/segmente,ge,350,then
   *get,_wa,node,,mxloc,y               ! Endwinkel
   _we=0
   *endif
   rsys,100
   path,pfad%_jj%,2,30,punkte
   ppath,1,node(rinnen+jochdicke2+delta/2,_wa,0),,,1
   ppath,2,node(rinnen+jochdicke2+delta/2,_we,0),,,1
   dsys
   _wa=_we
   ! Label f. Lufspaltfeld
   pdef,_bx,b,x
   pdef,_by,b,y
   !    computes the angle
   pcalc,add,cir,s,,,,_cur_l
   pcalc,add,ang,cir,,(1/(rinnen+jochdicke2+delta/2))*180/3.141593
   *get,_cur_l,path,,max,cir
   rsys
   csys


  *set,_unsort
  paget,_unsort,table
  ! sortieren der Daten fuer spaetere Anwendung
  *vfun,_path(1+_snn,0),copy,_unsort(1,18)
  *vfun,_path(1+_snn,1),copy,_unsort(1,16)
  *vfun,_path(1+_snn,2),copy,_unsort(1,17)
  *vfun,_path(1+_snn,3),copy,_unsort(1,8)
  *vfun,_path(1+_snn,4),copy,_unsort(1,12)
  *vfun,_path(1+_snn,5),copy,_unsort(1,15)
  *vfun,_path(1+_snn,6),copy,_unsort(1,5)
  *vfun,_path(1+_snn,7),copy,_unsort(1,6)
  _snn=punkte+_snn

*enddo
! ***** ENDE LOOP UEBER ALLE SEGMENTE *******************************************

 *endif
*endif
! ***************************************************************************
! ****** ENDE der Pfadbereitstellung fuer Momentberechnung ******************
! ****** und Luftspaltfeld **************************************************
! ***************************************************************************


! ***************************************************************************
! ***** Luftspaltfeld *******************************************************
! ***************************************************************************
_lsfeld=1

*if,_lsfeld,eq,1,then
 /reset
 /axlab,x,Pfadwinkel in Grad (CCW)
 /axlab,y,B_r (B_t) in T
 /grid,1
 /xrange,0,360
!! /yrange,-1,1
 /GCOL,1,'B radial'
 /GCOL,2,'B tangential'
!! _qk=_nust(_us,1)               ! Winkel
 /title,Luftspaltfeld der Maschine 
/show,Plots%ausgabe%,grph,,append
 *vplo,_path(1,3),_path(1,6),7
 _nonie=1
*endif

_fft=1

*if,_fft,eq,1,then

_asy=1
_womit=0
_modemax=30

 _mode=
 _coeff=
 _coeff1=
 _coeff2=
 _coeff_0=
 _coeff_1=
 _phix=
 _phiy=
 _isy1=
 _isy0=
 _feld=6+%_womit%

 *dim,_mode,array,_modemax
 *vfill,_mode(1),ramp,0,1,
 *dim,_coeff_0,array,_modemax
 *dim,_coeff_1,array,_modemax
 *dim,_isy0,array,_modemax
 *vfill,_isy0(1),ramp,1,0
 *dim,_isy1,array,_modemax
 *vfill,_isy1(1),ramp,-1,0
 *dim,_phix,table,segmente*punkte
 *dim,_phiy,table,segmente*punkte
 *dim,_coeff,array,_modemax-1,
 *dim,_coeff1,array,_modemax-1,
 *dim,_coeff2,array,_modemax-1,

 *voper,_phix(1),_phix(1),add,_path(1,3)
 *voper,_phiy(1),_phiy(1),add,_path(1,_feld)

 *mfour,fit,_coeff_1(1),_mode(1),_isy1(1),_phix(1),_phiy(1)
  /axlab,y,Koeff. der geraden per. Funktion
  *mfour,fit,_coeff_0(1),_mode(1),_isy0(1),_phix(1),_phiy(1)
  /axlab,y,Koeff. der ungeraden per. Funktion
 *endif
 /axlab,x,Mode Nummer
 *if,%_womit%,eq,1,then
 /title,Fourierreihenzerlegung Tangentialfeld
 *else
 /title,Fourierreihenzerlegung Radialfeld
 *endif
 /grop,fill,1
 /gthk,axis,3
 /gropt,divx,_modemax-1
 /xrange,1,_modemax
 /gropt,ltyp,0
 /gcolu,1,koeff
!! *voper,_coeff(1),_coeff(1),add,_coeff_%_asy%(2)
*voper,_coeff(1),_coeff_0(1),mult,_coeff_0(1)
*voper,_coeff1(1),_coeff_1(1),mult,_coeff_1(1)
*voper,_coeff2(1),_coeff(1),add,_coeff1(1)
*vfun,_coeff(1),sqrt,_coeff2(1)
/show,Plots%ausgabe%,grph,,append
 *vplot,_mode(1),_coeff(1)
 !*stat,_coeff
 _nonie=1
*endif
